package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 合同
 * </p>
 *
 * @author clm
 * @since 2022-06-08
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("pay_contract")
@ApiModel(value = "Contract", description = "合同")
@AllArgsConstructor
public class Contract extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 系统code
     */
    @ApiModelProperty(value = "系统code")
    @Size(max = 20, message = "系统code长度不能超过20")
    @TableField(value = "system_code", condition = LIKE)
    @Excel(name = "系统code")
    private String systemCode;

    /**
     * 业务系统主键
     */
    @ApiModelProperty(value = "业务系统主键")
    @NotNull(message = "请填写业务系统主键")
    @TableField(value = "contract_id")
    @Excel(name = "业务系统主键")
    private Long contractId;

    /**
     * 合同编号
     */
    @ApiModelProperty(value = "合同编号")
    @Size(max = 20, message = "合同编号长度不能超过20")
    @TableField(value = "contract_number", condition = LIKE)
    @Excel(name = "合同编号")
    private String contractNumber;

    /**
     * 合同名称
     */
    @ApiModelProperty(value = "合同名称")
    @Size(max = 50, message = "合同名称长度不能超过50")
    @TableField(value = "contract_name", condition = LIKE)
    @Excel(name = "合同名称")
    private String contractName;

    /**
     * 展会id
     */
    @ApiModelProperty(value = "展会id")
    @TableField(value = "exhibition_id")
    @Excel(name = "展会id")
    private Long exhibitionId;

    /**
     * 展会名称
     */
    @ApiModelProperty(value = "展会名称")
    @Size(max = 255, message = "展会名称长度不能超过255")
    @TableField(value = "exhibition_name", condition = LIKE)
    @Excel(name = "展会名称")
    private String exhibitionName;

    /**
     * 合同金额
     */
    @ApiModelProperty(value = "合同金额")
    @TableField(value = "contract_amount")
    @Excel(name = "合同金额")
    private BigDecimal contractAmount;

    /**
     * 乙方id(按客户名称查询如库里有则不为空)
     */
    @ApiModelProperty(value = "乙方id(按客户名称查询如库里有则不为空)")
    @TableField(value = "cutomer_id")
    @Excel(name = "乙方id(按客户名称查询如库里有则不为空)")
    private Long cutomerId;

    /**
     * 乙方名称
     */
    @ApiModelProperty(value = "乙方名称")
    @Size(max = 255, message = "乙方名称长度不能超过255")
    @TableField(value = "cutomer_name", condition = LIKE)
    @Excel(name = "乙方名称")
    private String cutomerName;

    /**
     * 乙方法人代表
     */
    @ApiModelProperty(value = "乙方法人代表")
    @Size(max = 255, message = "乙方法人代表长度不能超过255")
    @TableField(value = "customer_legal", condition = LIKE)
    @Excel(name = "乙方法人代表")
    private String customerLegal;

    /**
     * 乙方统一代码
     */
    @ApiModelProperty(value = "乙方统一代码")
    @Size(max = 20, message = "乙方统一代码长度不能超过20")
    @TableField(value = "customer_uscc", condition = LIKE)
    @Excel(name = "乙方统一代码")
    private String customerUscc;

    /**
     * 乙方地址
     */
    @ApiModelProperty(value = "乙方地址")
    @Size(max = 255, message = "乙方地址长度不能超过255")
    @TableField(value = "customer_address", condition = LIKE)
    @Excel(name = "乙方地址")
    private String customerAddress;

    /**
     * 开始时间
     */
    @ApiModelProperty(value = "开始时间")
    @TableField(value = "start_time")
    @Excel(name = "开始时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime startTime;

    /**
     * 结束时间
     */
    @ApiModelProperty(value = "结束时间")
    @TableField(value = "end_time")
    @Excel(name = "结束时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime endTime;

    /**
     * 签单日期
     */
    @ApiModelProperty(value = "签单日期")
    @TableField(value = "signing_time")
    @Excel(name = "签单日期", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime signingTime;

    /**
     * 我方签单人
     */
    @ApiModelProperty(value = "我方签单人")
    @Size(max = 255, message = "我方签单人长度不能超过255")
    @TableField(value = "signatory_name", condition = LIKE)
    @Excel(name = "我方签单人")
    private String signatoryName;

    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    @Size(max = 255, message = "备注长度不能超过255")
    @TableField(value = "remark", condition = LIKE)
    @Excel(name = "备注")
    private String remark;

    /**
     * 合同url
     */
    @ApiModelProperty(value = "合同url")
    @Size(max = 255, message = "合同url长度不能超过255")
    @TableField(value = "contract_url", condition = LIKE)
    @Excel(name = "合同url")
    private String contractUrl;
    /**
     * 场地保证金
     */
    @ApiModelProperty(value = "场地保证金")
    @TableField(value = "space_bond")
    @Excel(name = "场地保证金")
    private BigDecimal spaceBond;

    /**
     * 服务预存款
     */
    @ApiModelProperty(value = "服务预存款")
    @TableField(value = "service_bond")
    @Excel(name = "服务预存款")
    private BigDecimal serviceBond;

    /**
     * 场地费用
     */
    @ApiModelProperty(value = "场地费用")
    @TableField(value = "space_amount")
    @Excel(name = "场地费用")
    private BigDecimal spaceAmount;

    /**
     * 已开票金额
     */
    @ApiModelProperty(value = "已开票金额")
    @TableField(value = "invoiced_amount")
    @Excel(name = "已开票金额")
    private BigDecimal invoicedAmount;

    /**
     * 合同付款状态
     */
    @ApiModelProperty(value = "合同付款状态")
    @TableField(value = "contract_pay_state")
    @Excel(name = "合同付款状态")
    private String contractPayState;

    /**
     * 合同回款金额
     */
    @ApiModelProperty(value = "合同回款金额")
    @TableField(value = "contract_returnd_amount")
    @Excel(name = "合同回款金额")
    private BigDecimal contractReturndAmount;

    @Builder
    public Contract(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime, 
                    Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId, 
                    String systemCode, Long contractId, String contractNumber, String contractName, Long exhibitionId, String exhibitionName, 
                    BigDecimal contractAmount, Long cutomerId, String cutomerName, String customerLegal, String customerUscc, String customerAddress, 
                    LocalDateTime startTime, LocalDateTime endTime, LocalDateTime signingTime, String signatoryName, String remark, String contractUrl) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.systemCode = systemCode;
        this.contractId = contractId;
        this.contractNumber = contractNumber;
        this.contractName = contractName;
        this.exhibitionId = exhibitionId;
        this.exhibitionName = exhibitionName;
        this.contractAmount = contractAmount;
        this.cutomerId = cutomerId;
        this.cutomerName = cutomerName;
        this.customerLegal = customerLegal;
        this.customerUscc = customerUscc;
        this.customerAddress = customerAddress;
        this.startTime = startTime;
        this.endTime = endTime;
        this.signingTime = signingTime;
        this.signatoryName = signatoryName;
        this.remark = remark;
        this.contractUrl = contractUrl;
    }

}
